// 首页SCADA的api
import request from '@/utils/request'
import { Message } from 'element-ui'

/**
 *获取设备信息详情api
 */
export const GetDeviceDataApi = (data) => request({
  method: 'post',
  url: `/DeviceData/GetDeviceData?deviceName=${data}`,
  data
})
/** 处理设备操作 */
export async function HandleDeviceOperate(vue, deviceCode, requestNo) {
  vue.$confirm('确认执行该操作吗？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async () => {
    await CreateNewDeviceMsgApi({ deviceCode: deviceCode, request: requestNo })
    Message.success('操作成功')
  }).catch(() => {
  })
}
/**
 *创建新的设备消息队列
 */
export const CreateNewDeviceMsgApi = (data) => request({
  method: 'post',
  url: '/DeviceMsgQueue/CreateNewDeviceMsg',
  data
})

/**
 * MES 在线离线
 */
export const UpdateConfigValueApi = (data) => request({
  method: 'post',
  url: '/Common/UpdateConfigValue',
  data
})

/**
 * 获取 每周入库 出库 任务总数柱状图当前数据的api
 */
export const CountWeekTaskApi = (data) => request({
  method: 'post',
  url: '/Chart/CountWeekTask',
  data
})

/**
 * 获取 每周入库 出库 任务总数折线图当前数据的api
 */
export const LineWeekTaskApi = (data) => request({
  method: 'post',
  url: '/Chart/LineWeekTask',
  data
})

/**
 * 获取 库存统计数据的api
 */
export const ChartLocationApi = (data) => request({
  method: 'post',
  url: '/Chart/ChartLocation',
  data
})

/**
 * 获取 货架数据的api
 */
export const GetShelfChartDataApi = (data) => request({
  method: 'post',
  url: '/Chart/GetShelfChartData',
  data
})

/**
 * 获取 设备统计的api
 */
export const ChartEquipmentApi = (data) => request({
  method: 'post',
  url: '/Chart/ChartEquipment',
  data
})

/**
 * 获取 "正在执行任务数",
      "正在执行的入库数",
      "等待执行的入库数",
      "正在执行的出库数",
      "等待执行的出库数"的api
 */
export const CountNowTaskApi = (data) => request({
  method: 'post',
  url: '/Chart/CountNowTask',
  data
})

/**
 * 获取 报表数据 的api
 */
export const GetChatDataApi = (data) => request({
  method: 'post',
  url: '/Chart/GetChartData',
  data
})


/**
 * 获取 查看当前设备离线还是在线api
 */
export const QueryConfigValue = () => request({
  method: 'post',
  url: '/Common/QueryConfigValue?configKey=IsOnline'
})
